//package com.example.demo.controller;
//
//import com.example.demo.entity.Student;
//import com.example.demo.service.StudentService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//
//@Controller
//public class StudentController {
//    @Autowired
//    private StudentService studentService;
//
//    @GetMapping("/student/all")
//    public String all(Model model) {
//        List<Student> students=studentService.findAll();
//        model.addAttribute("students", students);
//        return "student";
//    }
//    @GetMapping("/student/add")
//    public String add() {
//        return "add";
//    }
//    @PostMapping("/student/add")
//    public String addStudent(@RequestParam("name") String name,@RequestParam("age") Integer age) {
//        studentService.addStudent(name,age);
//        return "redirect:/student/all";
//    }
//    @GetMapping("/student/update/{id}")
//    public String update(@PathVariable("id") Integer id, Model model) {
//        Student student=studentService.findById(id);
//        model.addAttribute("student", student);
//        return "update";
//
//    }
//    @GetMapping("/student/update/{id}")
//    public String updateStudent(@PathVariable("id") Integer id,@RequestParam("age") Integer age,@RequestParam("name") String name) {
//        studentService.updateStudent(id,name,age);
//        return "redirect:/student/all";
//
//    }
//    @GetMapping("/student/delete/{id}")
//    public String delete(@PathVariable("id") Integer id) {
//        studentService.deleteStudentById(id);
//        return "redirect:/student/all";
//    }
//}
